<template>
  <div class="item">
    <div class="content">
      <div class="title" v-html="item.title"></div>
      <div class="info">
        <div class="time">{{ date }}</div>
        <div class="see"><van-icon name="eye-o" />{{ item.read }}</div>
        <div class="good">
          <good-job
            :id="item.id"
            :class="`${list.includes(item.id) ? 'active' : ''}`"
          />{{ item.star }}
        </div>
      </div>
    </div>
    <div>
      <img
        v-if="!(item.cover === null)"
        class="skillsImg"
        :src="imgHost + item.cover"
        alt=""
      />
    </div>
  </div>
</template>

<script>
import GoodJob from '@/components/Find/GoodJob.vue'
import dayjs from 'dayjs'
export default {
  components: {
    GoodJob
  },
  data () {
    return {
      date: '',
      imgHost: 'http://hmmm.zllhyy.cn/',
      list: []
    }
  },
  props: {
    item: {
      required: true,
      type: Object
    }
  },
  methods: {
    getDate () {
      const res = Date.parse(this.item.created_at)
      const date = dayjs(res).format('YYYY-MM-DD')
      this.date = date
      if (localStorage.getItem('goodList')) {
        this.list = JSON.parse(localStorage.getItem('goodList'))
      }
    }
  },
  created () {
    this.getDate()
  },
}
</script>

<style lang="less" scoped>
.item {
  margin-top: 0.3125rem;
  display: flex;
  justify-content: space-between;
  padding: 0.9375rem;
  padding-top: 0;
  .content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .title {
      color: #181a39;
      font-weight: 500;
    }
    .info {
      color: #b4b4bd;
      font-size: 0.75rem;
      display: flex;
      margin-right: 20px;
      // justify-content: space-between;
      .time {
        flex: 1;
      }
      .see {
        margin-right: 20px;
      }
      .active {
        color: #e40137 !important;
      }
    }
  }
  .skillsImg {
    width: 7.5rem;
    height: 5rem;
  }
}
</style>
